<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>创建学校</title>
    <link rel="stylesheet" type="text/css" href="../plugin/layui/css/layui.css" />
    <script src="../plugin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script>
        layui.use(['form','layer','jquery','laydate'], function(){
            var form = layui.form,layer=layui.layer,$=layui.jquery,laydate=layui.laydate;
            $.get("../school/alls",function (res) {
                console.log(res)
                var selector=document.getElementById("select");
                var option=document.createElement("option");
                option.innerText="请选择";
                selector.appendChild(option);
                for (var i=0;i<res.data.length;i++){
                    var option=document.createElement("option");
                    option.innerText=res.data[i].sname;
                    option.value=res.data[i].sid;
                    selector.append(option);
                };
                form.render("select");
            });
            laydate.render({
                elem:'#graduateTime'
            });
            laydate.render({
                elem:'#birthday'
            });
            //监听提交
            form.on('submit(leader)', function(data){
                console.log(data.field);
                $.post("../leader/assign",data.field,function (res) {
                   if (res.code==0){
                       layer.msg(res.message,{icon: 1})
                   }else {
                       layer.msg(res.message,{icon: 5})
                   }
                });
                return false;
            });
        });
    </script>
</head>
<body>
<form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">校长账号</label>
        <div class="layui-input-block">
            <input type="text" name="account" required  lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码框</label>
        <div class="layui-input-inline">
            <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">校长名字</label>
        <div class="layui-input-block">
            <input type="text" name="lname" required  lay-verify="required" placeholder="请输入校长名字" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input type="text" name="phone" required  lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">毕业院校</label>
        <div class="layui-input-block">
            <input type="text" name="graduate" required  lay-verify="required" placeholder="请输入毕业院校" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">毕业时间</label>
        <div class="layui-inline"> <!-- 注意：这一层元素并不是必须的 -->
            <input type="text" class="layui-input" id="graduateTime" placeholder="请选择毕业时间" name="graduateTime">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">负责学校</label>
        <div class="layui-input-block">
            <select name="sid" lay-verify="required" id="select"></select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出生日期</label>
        <div class="layui-inline"> <!-- 注意：这一层元素并不是必须的 -->
            <input type="text" class="layui-input" id="birthday" placeholder="请选择生日" name="birthday">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="gender" value="男" title="男" checked>
            <input type="radio" name="gender" value="女" title="女">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">工作经历</label>
        <div class="layui-input-block">
            <textarea name="workHistory" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="leader">提交</button>
        </div>
    </div>
</form>
</body>
</html>